# @Time    : 2022/8/23 11:14
# @Author  : SunJian
# @Email   : 330160114@qq.com
# @File    : calc.py
# @Software: PyCharm
"""
文件说明：
pytest模块快速使用
"""


# class MyCalc():
#     @staticmethod
#     def add(a,b):
#         return a+b
#
#     @staticmethod
#     def minus(a,b):
#         return a-b
#
#     def multiply(self,a,b):
#         return a*b
#
#     def divide(self,a,b):
#         return a/b


import requests
import base64
from PIL import Image

'''
人像动漫化
'''

host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=y97a6xULfpZk5WeeiR6p5Fab&client_secret=waH59pQLyO8iCzz6XM1VlTi00rMycBWp'
response = requests.get(host)
print(response.json())

request_url = "https://aip.baidubce.com/rest/2.0/image-process/v1/selfie_anime"
# 二进制方式打开图片文件
image = Image.open('‪321123.jpg')
image.show()
img = base64.b64encode(image)
params = {"image":img}
access_token = response.json()['access_token']
request_url = request_url + "?access_token=" + access_token
headers = {'content-type': 'application/x-www-form-urlencoded'}
response = requests.post(request_url, data=params, headers=headers)
if response:
    print (response.json())



